package com.gaohe.web.controller.scp;

import java.util.List;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.gaohe.common.annotation.Log;
import com.gaohe.common.core.controller.BaseController;
import com.gaohe.common.core.domain.AjaxResult;
import com.gaohe.common.enums.BusinessType;
import com.gaohe.scp.domain.CsCarAssess;
import com.gaohe.scp.service.ICsCarAssessService;
import com.gaohe.common.utils.poi.ExcelUtil;
import com.gaohe.common.core.page.TableDataInfo;

/**
 * 车辆评估Controller
 *
 * @author liuxiangyu
 * @date 2025-03-25
 */
@RestController
@RequestMapping("/scp/assess")
public class CsCarAssessController extends BaseController
{
    @Autowired
    private ICsCarAssessService csCarAssessService;

    // 通过carId查询查询车辆评估------牛相善
//    @PreAuthorize("@ss.hasPermi('scp:assess:query')")
    @GetMapping(value = "/car/{carId}")
    public TableDataInfo getAssessByCarId(@PathVariable("carId") Long carId)
    {
        List<CsCarAssess> list=csCarAssessService.selectCsCarAssessByCarId(carId);
        return getDataTable(list);
    }
    /**
     * 查询车辆评估列表
     */
//    @PreAuthorize("@ss.hasPermi('scp:assess:list')")
    @GetMapping("/list")
    public TableDataInfo list(CsCarAssess csCarAssess)
    {
        startPage();
        List<CsCarAssess> list = csCarAssessService.selectCsCarAssessList(csCarAssess);
        return getDataTable(list);
    }

    /**
     * 导出车辆评估列表
     */
//    @PreAuthorize("@ss.hasPermi('scp:assess:export')")
    @Log(title = "车辆评估", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CsCarAssess csCarAssess)
    {
        List<CsCarAssess> list = csCarAssessService.selectCsCarAssessList(csCarAssess);
        ExcelUtil<CsCarAssess> util = new ExcelUtil<CsCarAssess>(CsCarAssess.class);
        util.exportExcel(response, list, "车辆评估数据");
    }

    /**
     * 获取车辆评估详细信息
     */
//    @PreAuthorize("@ss.hasPermi('scp:assess:query')")
    @GetMapping(value = "/{assessId}")
    public AjaxResult getInfo(@PathVariable("assessId") Long assessId)
    {
        return success(csCarAssessService.selectCsCarAssessByAssessId(assessId));
    }

    /**
     * 新增车辆评估
     */
//    @PreAuthorize("@ss.hasPermi('scp:assess:add')")
    @Log(title = "车辆评估", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CsCarAssess csCarAssess)
    {
        return toAjax(csCarAssessService.insertCsCarAssess(csCarAssess));
    }

    /**
     * 修改车辆评估
     */
//    @PreAuthorize("@ss.hasPermi('scp:assess:edit')")
    @Log(title = "车辆评估", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CsCarAssess csCarAssess)
    {
        return toAjax(csCarAssessService.updateCsCarAssess(csCarAssess));
    }

    /**
     * 删除车辆评估
     */
//    @PreAuthorize("@ss.hasPermi('scp:assess:remove')")
    @Log(title = "车辆评估", businessType = BusinessType.DELETE)
	@DeleteMapping("/{assessIds}")
    public AjaxResult remove(@PathVariable Long[] assessIds)
    {
        return toAjax(csCarAssessService.deleteCsCarAssessByAssessIds(assessIds));
    }
}
